home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2614.ZIP / PGRAPH.ZIP / PGRAPH.PRG next >
Text File  |  1990-11-18  |  14KB  |  441 lines

  1. *************************************************************************
  2. ***  Demonstration and Source Code of 'Progress' Graphs               ***
  3. ***  Courtesy of TJS LAB, Orlando, Florida 32858-5366 (407) 291-3960  ***
  4. ***  Compile with Clipper Summer 87 or 5.0                            ***
  5. *************************************************************************
  6. fpainth()   && 'paint' the main screen
  7. fmakedb()   && make a sample database with 50 records or just open database
  8. declare arrtemp[7]   && to contain the menu for the various graphs
  9. arrtemp[1]="Standard Sliding Bar Along a Line"
  10. arrtemp[2]="Standard Sliding Bar Within A Box"
  11. arrtemp[3]="Vertical Bar (Thermometer)"
  12. arrtemp[4]="Exploding Boxes"
  13. arrtemp[5]="Multiple Boxes"
  14. arrtemp[6]="Hour Glass"
  15. arrtemp[7]="Demo ALL!"
  16. opt=1  &&  initial selection choice
  17. set cursor off
  18. do while .t.
  19.    opt=achoice(8, 36, 13, 77, arrtemp,.T.,"",opt,0)
  20.    do case             && determine which graph to display
  21.       case opt=1
  22.        report1()   && Standard Sliding Bar Along a Line
  23.       case opt=2
  24.        report2()   && Standard Sliding Bar Within a Box
  25.       case opt=3
  26.        report3()   && Vertical Bar (Thermometer)
  27.       case opt=4
  28.        report4()   && Exploding Boxes
  29.       case opt=5
  30.        report5()   && Multiple Boxes
  31.       case opt=6
  32.        report6()   && Hour Glass
  33.       case opt=7
  34.        report7()   && Demo All
  35.       case opt=0
  36.        exit        && Exit Program
  37.    endcase
  38.    keyboard chr(24)    && move down to next menu option...
  39.    set color to W+/N
  40. enddo
  41. set cursor on
  42. set color to W/N
  43. @ 24,0
  44. ?
  45. return
  46.  
  47. function fpainth   &&  'paint' the main screen for this program
  48. set color to B+/N
  49. clear
  50. @ 1,0 to 23,79 double
  51. @ 23,60 say "[ TJS LAB ]"
  52. set color to W+/R
  53. @ 1,23 say "[ PROGRESS GRAPH DEMONSTRATION ]"
  54. set color to BG+/N
  55. @ 3,5 say "The purpose of this program is to demonstrate the use of 'Progress'"
  56. @ 4,5 say "graphs on the screen during program execution."
  57. @ 5,5 say "Progress graphs tend to make programs execute slightly slower, but"
  58. @ 6,5 say "the effect of 'bells & whistles' sometimes outweighs time..."
  59. set color to GR+/N
  60. @ 8,5  say "This program demonstrates the use of a variety of progress graphs"
  61. @ 9,5  say "while it 'looks at' all records in a sample database."
  62. @ 10,5 say "You can use the progress graph in conjunction with many operations,"
  63. @ 11,5 say "ie, reports, counting, summing, or updating data..."
  64. set color to G+/N
  65. @ 13,5 say "This program is released into Public Domain.   No Copyright!"
  66. set color to W+/N
  67. @ 15,5 say "If you use any part of this source, please (but you do not have to)"
  68. @ 16,5 say "donate $10.00 payable to:"
  69. @ 18,5 say "Orlando Clipper Users Group (O.C.U.G.)"
  70. @ 19,5 say "c/o Tom Rouse, President"
  71. @ 20,5 say "P.O. Box 585366"
  72. @ 21,5 say "Orlando, Florida 32858-5366"
  73. kwait()   && pause for 60 seconds or until any key is pressed
  74. set color to B+/N
  75. @ 7,35 clear to 15,78
  76. @ 7,35 to 15,78 double
  77. set color to W+*/B
  78. @ 14,36 say  "              Select Option!              "
  79. set color to W+/N
  80. return ""
  81.  
  82. function fmakedb    && make sample.dbf with 50 records or just open database
  83. if !file("sample.dbf")
  84.    create sample.$$$
  85.    use sample.$$$ exclusive
  86.    append blank
  87.    replace field_name with "ITEM"
  88.    replace field_type WITH "C"
  89.    replace field_len WITH 12
  90.    append blank
  91.    replace field_name with "DESC"
  92.    replace field_type WITH "C"
  93.    replace field_len WITH 30
  94.    append blank
  95.    replace field_name with "QTY"
  96.    replace field_type WITH "N"
  97.    replace field_len WITH 10
  98.    replace field_dec WITH 3
  99.    use
  100.    create sample from sample.$$$
  101.    erase sample.$$$
  102.    for i=1 to 50  && make the 50 records...
  103.        append blank
  104.        replace item with "XXX"+ltrim(str(I))
  105.        replace desc with ltrim(str(i))+" - Description"
  106.        replace qty with recno()*2.984
  107.    next
  108. else
  109.    use sample exclusive
  110. endif
  111. return ""
  112.  
  113. function kwait  && pause for 60 seconds...
  114. set color to W+*/N
  115. @ 24,0 say "Press any key to continue..."
  116. keyboard ""
  117. inkey(60)
  118. set color to W/N
  119. @ 24,0   && remove message
  120. return ""
  121.  
  122. function report1   && Sliding Bar Along a Line
  123. save screen to scrn1
  124. goto top    && start at the top of the file...
  125. fslide1()   && paint the line graph onto the screen
  126. ii=0        && graph counter
  127. do while !eof()
  128.    ii=ii+1
  129.    @ 23,6 say replicate(chr(219),(ii/lastrec())*68)
  130.    inkey(.1)         && pause for visual effects....
  131.  
  132.    *  Here, you would put your routines that report, count and/or update
  133.  
  134.    skip
  135. enddo
  136. kwait()  && pause for 60 seconds...
  137. restore screen from scrn1
  138. return ""
  139.  
  140. function report2   && Sliding Bar Within A Box
  141. save screen to scrn1
  142. goto top    && start at the top of the file...
  143. fslide2()   && paint the Box graph onto the screen
  144. ii=0        && graph counter
  145. do while !eof()
  146.    ii=ii+1
  147.    @ 4,8 say replicate(chr(219),(ii/lastrec())*66)
  148.    inkey(.1)         && pause for visual effects....
  149.  
  150.    *  Here, you would put your routines that report, count and/or update
  151.  
  152.    skip
  153. enddo
  154. kwait()  && pause for 60 seconds...
  155. restore screen from scrn1
  156. return ""
  157.  
  158. function report3   && Vertical Bar/Thermometer
  159. save screen to scrn1
  160. goto top           && start at the top of the file...
  161. fthermo(0,"X")     && paint the Vertical/Thermo graph onto the screen
  162. ii=0               && graph counter
  163. do while !eof()
  164.    ii=ii+1
  165.    fthermo(ii)     && update the Vertical/Thermo graph
  166.    inkey(.1)       && pause for visual effects....
  167.  
  168.    *  Here, you would put your routines that report, count and/or update
  169.  
  170.    skip
  171. enddo
  172. kwait()  && pause for 60 seconds...
  173. restore screen from scrn1
  174. return ""
  175.  
  176. function report4     && Exploding Box
  177. save screen to scrn1
  178. goto top             && start at the top of the file...
  179. ii=0                 && graph counter
  180. set color to W+/B
  181. do while !eof()
  182.    ii=ii+1
  183.    fexbox(ii,11,65)  && exploding box progress graph: counter,row,column
  184.    inkey(.1)         && pause for visual effects....
  185.  
  186.    *  Here, you would put your routines that report, count and/or update
  187.  
  188.    skip
  189. enddo
  190. kwait()  && pause for 60 seconds...
  191. restore screen from scrn1
  192. return ""
  193.  
  194. function report5   && Multiple Boxes
  195. save screen to scrn1
  196. goto top        && start at the top of the file...
  197. ii=0            && graph counter
  198. fmultibox(9,ii+1,.t.)  &&  paint the graph box...
  199. do while !eof()
  200.    ii=ii+1
  201.    fmultibox(9,ii,.f.)  &&  update the graph box...
  202.    inkey(.1)         && pause for visual effects....
  203.  
  204.    *  Here, you would put your routines that report, count and/or update
  205.  
  206.    skip
  207. enddo
  208. kwait()  && pause for 60 seconds...
  209. restore screen from scrn1
  210. return ""
  211.  
  212. function report6   && Hour Glass
  213. save screen to scrn1
  214. goto top           && start at the top of the file...
  215. ii=0               && graph counter
  216. fhglass(ii,"X")    &&  paint the graph box...
  217. set color to W+/N
  218. do while !eof()
  219.    ii=ii+1
  220.    fhglass(ii)       &&  update the graph box...
  221.    inkey(.1)         && pause for visual effects....
  222.  
  223.    *  Here, you would put your routines that report, count and/or update
  224.  
  225.    skip
  226. enddo
  227. kwait()  && pause for 60 seconds...
  228. restore screen from scrn1
  229. return ""
  230.  
  231. function report7   && Demo ALL!
  232. save screen to scrn1
  233. goto top    && start at the top of the file...
  234. fslide1()   && paint the line graph onto the screen
  235. ii=0        && graph counter
  236. do while !eof()
  237.    ii=ii+1
  238.    @ 23,6 say replicate(chr(219),(ii/lastrec())*68)
  239.    inkey(.1)         && pause for visual effects....
  240.    skip
  241. enddo
  242. goto top    && start at the top of the file...
  243. fslide2()   && paint the Box graph onto the screen
  244. ii=0        && graph counter
  245. do while !eof()
  246.    ii=ii+1
  247.    @ 4,8 say replicate(chr(219),(ii/lastrec())*66)
  248.    inkey(.1)         && pause for visual effects....
  249.    skip
  250. enddo
  251. goto top        && start at the top of the file...
  252. fthermo(0,"X")  && paint the Vertical/Thermo graph onto the screen
  253. ii=0            && graph counter
  254. do while !eof()
  255.    ii=ii+1
  256.    fthermo(ii)      && update the Vertical/Thermo graph
  257.    inkey(.1)        && pause for visual effects....
  258.    skip
  259. enddo
  260. goto top        && start at the top of the file...
  261. ii=0            && graph counter
  262. set color to W+/B
  263. do while !eof()
  264.    ii=ii+1
  265.    fexbox(ii,11,65)  && exploding box progress graph: counter,row,column
  266.    inkey(.1)         && pause for visual effects....
  267.    skip
  268. enddo
  269. goto top        && start at the top of the file...
  270. ii=0            && graph counter
  271. fmultibox(9,ii+1,.t.)  &&  paint the graph box...
  272. do while !eof()
  273.    ii=ii+1
  274.    fmultibox(9,ii,.f.)  &&  update the graph box...
  275.    inkey(.1)            && pause for visual effects....
  276.    skip
  277. enddo
  278. goto top          && start at the top of the file...
  279. ii=0              && graph counter
  280. fhglass(ii,"X")   && paint the graph box...
  281. set color to W+/N
  282. do while !eof()
  283.    ii=ii+1
  284.    fhglass(ii)       &&  update the graph box...
  285.    inkey(.1)         && pause for visual effects....
  286.    skip
  287. enddo
  288. kwait()  && pause for 60 seconds...
  289. restore screen from scrn1
  290. return ""
  291.  
  292. function fslide1   && Standard Sliding Bar Along A Line
  293. set color to BG+/N
  294. @ 22,6 say  "0                               50%                            Finis"
  295. set color to B+/N
  296. @ 23,5 say   "╣──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──╠"   && 68 wide
  297. set color to BR+/N
  298. return ""
  299.  
  300. function fslide2   && Standard Sliding Bar Within A Box
  301. set color to B+/N
  302. @ 3,4 say "   ╔════════════════╤════════════════╤═══════════════╤════════════════╗"
  303. @ 4,4 say "   ╟────────────────┼────────────────┼───────────────┼────────────────╢"
  304. @ 5,4 say "╔══╬════════════════╪════════════════╪═══════════════╪════════════════╬══╗"
  305. @ 6,4 say "║                                                                        ║"
  306. @ 7,4 say "╚════════════════════════════════════════════════════════════════════════╝"
  307. set color to BG+/N
  308. @ 6,7 say "0% Completed∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙50%∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙Done!"
  309. set color to BR+/N
  310. return ""
  311.  
  312. function fthermo    && Vertical Bar/Thermometer
  313. parameter parm,parm1
  314. private parm,parm1
  315. if pcount()>1
  316.    set color to W+/B
  317.    @ 2,71  say "▄▄▄▄▄▄▄▄▄"
  318.    @ 3,71  say "║100%┬──╫"
  319.    @ 4,71  say "║  . │──║"
  320.    @ 5,71  say "║  . │──║"
  321.    @ 6,71  say "║ 83%┼──╫"
  322.    @ 7,71  say "║  . │──║"
  323.    @ 8,71  say "║  . │──║"
  324.    @ 9,71  say "║ 67%┼──╫"
  325.    @ 10,71 say "║  . │──║"
  326.    @ 11,71 say "║  . │──║"
  327.    @ 12,71 say "║ 50%┼──╫"
  328.    @ 13,71 say "║  . │──║"
  329.    @ 14,71 say "║  . │──║"
  330.    @ 15,71 say "║ 33%┼──╫"
  331.    @ 16,71 say "║  . │──║"
  332.    @ 17,71 say "║  . │──║"
  333.    @ 18,71 say "║ 17%┼──╫"
  334.    @ 19,71 say "║  . │──║"
  335.    @ 20,71 say "║  . │──║"
  336.    @ 21,71 say "║  0%┴──╫"
  337.    @ 22,71 say "▀▀▀▀▀▀▀▀▀"
  338. endif
  339. set color to R+/N
  340. @ 21-(parm/lastrec())*18,77,21,78 box chr(219)+chr(219)+chr(219)+chr(219)+chr(219)+chr(219)+chr(219)+chr(219)+chr(219)
  341. return ""
  342.  
  343. function fexbox   && exploding box progress graph
  344. parameter parm,parm1,parm2
  345. private parm,parm1,parm2,parm3
  346. parm3=(parm/lastrec()+.0001)*10
  347. @ parm1-int(parm3),parm2-int(parm3) to parm1+2+int(parm3),parm2+3+int(parm3)
  348. @ parm1+1,parm2+1 say parm3*10 picture "99"
  349. *        ┌────────────────────┐
  350. *        │┌──────────────────┐│
  351. *        ││┌────────────────┐││
  352. *        │││┌──────────────┐│││
  353. *        ││││┌────────────┐││││
  354. *        │││││┌──────────┐│││││
  355. *        ││││││┌────────┐││││││
  356. *        │││││││┌──────┐│││││││
  357. *        ││││││││┌────┐││││││││
  358. *        │││││││││┌──┐│││││││││
  359. *        ││││││││││XX││││││││││
  360. *        │││││││││└──┘│││││││││
  361. *        ││││││││└────┘││││││││
  362. *        │││││││└──────┘│││││││
  363. *        ││││││└────────┘││││││
  364. *        │││││└──────────┘│││││
  365. *        ││││└────────────┘││││
  366. *        │││└──────────────┘│││
  367. *        ││└────────────────┘││
  368. *        │└──────────────────┘│
  369. *        └────────────────────┘
  370. RETURN ""
  371.  
  372. function fmultibox           && progress graph in the form of boxes...
  373. parameter parm,parm1,parm2   && parm is the top line...  parm1 is the counter
  374. private i,parm,parm1,parm2   && parm2 is the flag to print the 'blank' graph
  375. *                           ┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
  376. *                           │10%││20%││30%││40%││50%││60%││70%││80%││90%││100│
  377. *                           └───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘
  378. if parm2
  379.    set color to W/N
  380.    for i=1 to 10
  381.        @ parm,  15+(i-1)*5 to parm+2,19+(i-1)*5
  382.        @ parm+1,16+(i-1)*5 say ltrim(str(i*10,3,0))+iif(i=10,"","%")
  383.    next
  384.    return ""
  385. endif
  386. if ((parm1/lastrec())+.0001)*10 < 1
  387.    return ""
  388. endif
  389. for i=int( ((parm1/lastrec())+.0001)*10) to int( ((parm1/lastrec())+.0001)*10)
  390.     setcolor("W+/"+substr("B ,R ,G ,RB,GR,BG,G ,RB,R ,B ",1+(I-1)*3,2))
  391.     @ parm,15+(i-1)*5 clear to parm+2,19+(i-1)*5
  392.     @ parm,15+(i-1)*5 to parm+2,19+(i-1)*5
  393.     @ parm+1,16+(i-1)*5 say ltrim(str(i*10,3,0))+iif(i=10,"","%")
  394. next
  395. set color to W+/N
  396. return ""
  397.  
  398. function fhglass   && Hour Glass progress graph
  399. parameter parm,parm1
  400. private parm,parm1
  401. if pcount()>1
  402.    set color to B+/N
  403.    @ 1,3 clear to 20,26
  404.    @ 1,3 to 20,26 double
  405.    set color to W+/N
  406.    @ 2,7  say  "┌──────────────┐"
  407.    @ 3,7  say  "│              │"
  408.    @ 4,7  say  "│              │"
  409.    @ 5,7  say  "│              │"
  410.    @ 6,7  say  "│              │"
  411.    @ 7,7  say  "│              │"
  412.    @ 8,7  say  "└─────╖  ╓─────┘"
  413.    @ 9,13 say        "║  ║"
  414.    @ 10,13 say       "║  ║"
  415.    @ 11,7 say  "┌─────╜  ╙─────┐"
  416.    @ 12,7 say  "│100%          │"
  417.    @ 13,7 say  "│80%           │"
  418.    @ 14,7 say  "│60%           │"
  419.    @ 15,7 say  "│40%           │"
  420.    @ 16,7 say  "│20%           │"
  421.    @ 17,6 say "╔╧══════════════╧╗"
  422.    @ 18,6 say "║                ║"
  423.    @ 19,5 say"═╩════════════════╩═"
  424.    set color to N/B
  425.    @ 18,7 say " PROGRESS GLASS "
  426.    set color to W+/R
  427.    @ 3,8 clear to 7,21
  428. endif
  429. x1=int((parm/lastrec())*5.1)
  430. set color to W+/N
  431. @ 3,8 clear to 2+x1,21
  432. for i=8 to 16-x1
  433.     @ i,14 say "  "
  434.     set color to W+/N
  435.     @ i,14 say "  "
  436.     set color to W+/R
  437. next
  438. @ 17-x1,8 clear to 16,21
  439. set color to W+/N
  440. return ""
  441.